home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWASINKS_H
- #define FWASINKS_H
- //========================================================================================
- //
- // File: FWASinks.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWAUTODE_H
- #include "FWAutoDe.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // CLASS FW_CSink
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CSink FW_AUTO_DESTRUCT_OBJECT
- {
-
- public:
-
- FW_CSink();
- virtual ~ FW_CSink();
-
- // ---- Standard sink protocol
-
- virtual long GetReadableBytes() const = 0;
- virtual void Read(void * destination, long count) = 0;
-
- virtual long GetWritableBytes() const = 0;
- virtual void Write(const void* source, long count) = 0;
-
- public:
-
- // ---- Optimized sink protocol
-
- // These four methods make it possible to optimize sink access
- // to buffered devices that can expose their buffer.
- // Sinks that are not buffered, or cannot expose their buffer
- // will not be able to take advantage of this protocol. Such
- // sinks should not override these methods, as the default behavior
- // is correct in that case.
-
- // Note that the ODF Stream classes will take advantage of this
- // protocol for sinks that support it, but no other ODF classes
- // will, and it is not expected that these methods would be used
- // by other clients. We could therefore grant friend access
- // to the streams classes and then declare these functions
- // to be private, but that seems unnecessarily restrictive.
-
- virtual const void* ReadPeek(long& availableReadBytes);
- virtual void ReadPeekAdvance(long bytesRead);
-
- virtual void* WritePeek(long& availableWriteBytes);
- virtual void WritePeekAdvance(long bytesWritten);
-
- protected:
- FW_CSink(const FW_CSink& sink);
- FW_CSink& operator=(const FW_CSink& sink);
- };
-
-
- //========================================================================================
- // FW_CRandomAccessSink
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CRandomAccessSink : public FW_CSink
- {
-
- public:
-
- FW_CRandomAccessSink();
- virtual~ FW_CRandomAccessSink();
-
- virtual long GetReadableBytes() const;
-
- virtual long GetLength() const = 0;
- virtual void SetLength(long length) = 0;
- virtual long GetPosition() const = 0;
- virtual void SetPosition(long position) = 0;
-
- protected:
- FW_CRandomAccessSink(const FW_CRandomAccessSink& sink);
- FW_CRandomAccessSink& operator=(const FW_CRandomAccessSink& sink);
- };
-
-
- //========================================================================================
- // CLASS FW_CMemorySink
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CMemorySink : public FW_CRandomAccessSink
- {
-
- public:
-
- FW_CMemorySink(void* buffer, long capacity, long length=0);
- virtual ~ FW_CMemorySink();
-
- virtual void Read(void * destination, long count);
-
- virtual long GetWritableBytes() const;
- virtual void Write(const void* source, long count);
-
- virtual long GetLength() const;
- virtual void SetLength(long length);
- virtual long GetPosition() const;
- virtual void SetPosition(long position);
-
- // ---- Peek optimization
-
- virtual const void* ReadPeek(long& availableReadBytes);
- virtual void ReadPeekAdvance(long bytesRead);
- virtual void* WritePeek(long& availableWriteBytes);
- virtual void WritePeekAdvance(long bytesWritten);
-
- private:
-
- char* fBuffer;
- const long fCapacity;
- long fLength;
- long fPosition;
-
- FW_CMemorySink(const FW_CMemorySink& sink);
- FW_CMemorySink& operator=(const FW_CMemorySink& sink);
- // Shouldn't copy instances of this class.
- };
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-